﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class ICharacter
{
	protected Weapon m_Weapon = null;

	public void SetWeapon(IWeapon weapon)
	{
		if (m_Weapon != null)
			m_Weapon.Release();
		m_Weapon = weapon;
		//设置武器拥有者
		m_Weapon.SetOwener(this);
	}

	//获取武器
	public IWeapon GetWeapon()
	{
		return m_Weapon;
	}

	protected void SetWeaponAtkPlusValue(int value)
	{
		m_Weapon.SetAtkPlusValue(value);
	}

	protected void WeaponAttackTarget(ICharacter target)
	{
		m_Weapon.Fire(target);
	}

	//获取武器攻击力
	public void GetAtkValue()
	{
		return m_Weapon.GetAtkValue();
	}

	/// <summary>
	/// 获得攻击距离
	/// </summary>
	/// <returns></returns>
	public float GetAttackRange()
	{
		return m_Weapon.GetAtkRange();
	}
	/// <summary>
	/// 攻击目标
	/// </summary>
	/// <param name="target"></param>
	public abstract void Attack(ICharacter target);
	/// <summary>
	/// 被其他角色攻击
	/// </summary>
	/// <param name="attacker"></param>
	public abstract void UnderAttack(ICharacter attacker);
}

public class ISolider : ICharacter
{
	public override void Attack(ICharacter target)
	{
		WeaponAttackTarget(target);
	}

	public override void UnderAttack(ICharacter attacker)
	{
		...
	}
}

public class IEnemy:ICharacter
{
	public override void Attack(ICharacter target)
	{
		SetWeaponAtkPlusValue(m_Weapon.GetAtkPlusValue);
		WeaponAttackTarget(target);
	}

	public override void UnderAttack(ICharacter attacker)
	{
		...
	}
}